package com.bike.bikeserver.controller.backend;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import org.springframework.web.bind.annotation.*;

import com.bike.bikeserver.common.annotation.OperationLog;
import com.bike.bikeserver.common.core.domain.CommonResult;
import com.bike.bikeserver.domain.WXUser;
import com.bike.bikeserver.service.IWXUserService;
import com.bike.bikeserver.service.impl.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;

import static com.bike.bikeserver.constant.Constants.*;

/**
 * @version 1.0
 * @Author ZZX
 * @Date 2023/7/16 13:17
 */
@RestController
@RequestMapping("back/wxuser")
public class BackWXUserController
{
    @Autowired
    IWXUserService wxUserService;
    @Autowired
    SysRoleService sysRoleService;

    /**
     * 获取所有用户列表
     *
     * @return
     */
    @GetMapping("getUserList")
    public CommonResult getUserList()
    {
        return wxUserService.getUserList();
    }

    /**
     * 根据微信用户名模糊查询
     *
     * @param nickName
     * @return
     */
    @OperationLog(value = "根据微信用户名模糊查询用户信息:wxuser")
    @GetMapping("getUserLikeName")
    public CommonResult getUserLikeName(@RequestParam("nickName") String nickName)
    {
        return wxUserService.getUserLikeName(nickName);
    }

    /**
     * 根据用户id修改用户积分数
     *
     * @param wxUser
     * @return
     */
    @SaCheckPermission(value = {USER_RIGHT_EDIT, USER_RIGHT_ALL}, mode = SaMode.OR)
    @OperationLog(value = "根据id修改微信用户积分数:wxuser")
    @PutMapping("editScore")
    public CommonResult editScore(@RequestBody WXUser wxUser)
    {
        return wxUserService.editScore(wxUser);
    }

    /**
     * 根据用户id删除用户
     *
     * @param wxUser
     * @return
     */
    @SaCheckPermission(value = {USER_RIGHT_EDIT, USER_RIGHT_ALL}, mode = SaMode.OR)
    @OperationLog(value = "根据id删除微信用户:wxuser")
    @DeleteMapping("deleteWXUser")
    public CommonResult deleteWXUser(@RequestBody WXUser wxUser)
    {
        return wxUserService.deleteWXUser(wxUser);
    }

}